﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;
    using System.Xml;

    [ScriptType("SP.NavigationNodeCreationInformation", ValueObject=true, ServerTypeId="{7aaaa605-79a9-4fda-ae1e-db952e5083e0}")]
    public sealed class NavigationNodeCreationInformation : ClientValueObject
    {
        private bool m_asLastNode;
        private bool m_isExternal;
        private NavigationNode m_previousNode;
        private string m_title;
        private string m_url;

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = false;
            string str = peekedName;
            if (str != null)
            {
                if (!(str == "Title"))
                {
                    if (str == "Url")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_url = reader.ReadString();
                        return flag;
                    }
                    if (str == "IsExternal")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_isExternal = reader.ReadBoolean();
                        return flag;
                    }
                    if (str == "PreviousNode")
                    {
                        flag = true;
                        reader.ReadName();
                        this.PreviousNode.FromJson(reader);
                        return flag;
                    }
                    if (str == "AsLastNode")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_asLastNode = reader.ReadBoolean();
                    }
                    return flag;
                }
                flag = true;
                reader.ReadName();
                this.m_title = reader.ReadString();
            }
            return flag;
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override void WriteToXml(XmlWriter writer, SerializationContext serializationContext)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (serializationContext == null)
            {
                throw new ArgumentNullException("serializationContext");
            }
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Title");
            DataConvert.WriteValueToXmlElement(writer, this.Title, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Url");
            DataConvert.WriteValueToXmlElement(writer, this.Url, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "IsExternal");
            DataConvert.WriteValueToXmlElement(writer, this.IsExternal, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "PreviousNode");
            DataConvert.WriteValueToXmlElement(writer, this.PreviousNode, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "AsLastNode");
            DataConvert.WriteValueToXmlElement(writer, this.AsLastNode, serializationContext);
            writer.WriteEndElement();
        }

        [Remote]
        public bool AsLastNode
        {
            get
            {
                return this.m_asLastNode;
            }
            set
            {
                this.m_asLastNode = value;
            }
        }

        [Remote]
        public bool IsExternal
        {
            get
            {
                return this.m_isExternal;
            }
            set
            {
                this.m_isExternal = value;
            }
        }

        [Remote]
        public NavigationNode PreviousNode
        {
            get
            {
                return this.m_previousNode;
            }
            set
            {
                this.m_previousNode = value;
            }
        }

        [Remote]
        public string Title
        {
            get
            {
                return this.m_title;
            }
            set
            {
                this.m_title = value;
            }
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override string TypeId
        {
            get
            {
                return "{7aaaa605-79a9-4fda-ae1e-db952e5083e0}";
            }
        }

        [Remote]
        public string Url
        {
            get
            {
                return this.m_url;
            }
            set
            {
                this.m_url = value;
            }
        }
    }
}

